/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.Bill;

import entities.BillingTestDetail;
import java.util.ArrayList;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author Dell
 */
public class TableModelBillTestDetail implements TableModel {

    private ArrayList<BillingTestDetail> billTestList;
    private String header[];

    public void setHeader(String[] header) {
        this.header = header;
    }

    public String[] getHeader() {
        return header;
    }

    public TableModelBillTestDetail(ArrayList<BillingTestDetail> billTestList) {
        this.billTestList = billTestList;
    }




    @Override
    public int getRowCount() {
        if (billTestList != null) {
            return billTestList.size();
        } else {
            return 0;
        }
    }

    @Override
    public int getColumnCount() {
        return header.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
          return header[columnIndex];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
       if (columnIndex == 0) {
            return String.class;
        } else {
            return Float.class;
        }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
           return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
         if(columnIndex==0){
        return billTestList.get(rowIndex).getTest().getTestName();
    }
 else if(columnIndex==1){
     return billTestList.get(rowIndex).getTestCost();
 }
    return null;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
      //  throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }
}
